{% extends "base.html" %}

{% block title %}Remates{% endblock %}
{% block head %}Remate del {{ remate.fecha|date:"SHORT_DATE_FORMAT" }}
<link href="{{ STATIC_URL }}facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="{{ STATIC_URL }}facebox/facebox.js" type="text/javascript"></script>
{% endblock %}

{% block content %}
    {% if perms.gestion.add_itemsRemates %}
        <form method="POST" action="/remates/listado/items/{{ remate.id }}/">{% csrf_token %}
            <table class="formTableABM" align="center" style="width:400px">
                <tr>
                    <td class="formfieldleft">{{ form.numeroRemito.label_tag }}</td>
                    <td class="formfieldright">{{ form.numeroRemito }} {{ form.numeroLinea }} <input type="submit" value="+" /></td>
                </tr>
                {% if registro %}
                    <tr>
                        <td class="formfieldleft">Descripci&oacute;n:</td>
                        <td class="formfieldright">{{ registro.descripcion }} (Base: U$S {{ registro.base }})</td>
                    </tr>
                    <tr>
                        <td class="formfieldleft">Cliente:</td>
                        <td class="formfieldright">{{ registro.remito.cliente }}</td>
                    </tr>
                {% endif %}
            </table>
        </form>
        <br />
        {% if error %}<span style="font-weight:bold;color:red">{{ error }}</span><br />{% endif %}
        {% if registro %}<form method="POST" action="/remates/listado/items/articulo/{{ remate.id|cut:"." }}/{{ registro.id|cut:"." }}/">{% csrf_token %}<input type="submit" value="Agregar al listado" /></form>{% endif %}
        <br />
        <hr class="info">
    {% else %}
        <p>Usted no tiene permiso para agregar items del remate</p>
    {% endif %}
    <h3>Listado del remate</h3>
    <p>| <a href="/remates/listado/vendidos/items/{{ remate.id|cut:"." }}/">Ver listado de vendidos</a> |</p>
    <table class="tablesorter" align="center" id="sorter_clientes" border="0" cellpadding="0" cellspacing="1" style="width:970px;">
        <thead>
            <tr>
                <th>Lote</th>
                <th colspan="2">Art&iacute;culo</th>
                <th>Descripci&oacute;n</th>
                <th>Base</th>
                {% if perms.gestion.change_remates %}
                    <th colspan="2"></th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for obj in todo %}
                <tr>
                    <td style="width:5px;width:5px;font-weight:bold;">{{ obj.numeroLote }}</td>
                    <td style="width:15px;font-weight:bold;">{{ obj.articulo.remito.numeroRemito }}</td>
                    <td style="width:5px;font-weight:bold;">{{ obj.articulo.numeroLinea }}</td>
                    <td>{{ obj.articulo.descripcion|default_if_none:"" }}</td>
                    <td style="text-align:right;width:90px;">
                        <div class="montoIzq">U$S</div>
                        <div class="montoDer">{{ obj.articulo.base|default_if_none:"0"|floatformat:"2" }}</div>
                    </td>
                    {% if perms.gestion.change_remates %}
                        {% if not obj.vendido %}
                            <td class="right"><a href="/remates/vender/items/{{ obj.id|cut:"." }}/" rel="facebox">Vender</a></td>
                            <td class="right"><a href="/remates/check/items/{{ obj.id|cut:"." }}/">Eliminar</a></td>
                        {% else %}
                            <td class="right"><span style="color:grey; cursor:default">Vender</span></td>
                            <td class="right"><span style="color:grey; cursor:default">Eliminar</span></td>
                        {% endif %}
                    {% endif %}
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <br /><br /><br /><br /><br /><br />
{% endblock %}